package ltd.hanamaki.study.exception.demo02;

public class Application {

    public static void main(String[] args) {
        Application application = new Application();
        try {
            application.test(120);
        } catch (AgeOutOfBoundsException e) {
            e.printStackTrace();
        }

    }


    public void test(int age) throws AgeOutOfBoundsException{
        System.out.println("传递的年龄为：" + age);
        if (age < 1 || age > 100) {
            throw new AgeOutOfBoundsException(age);
        } else {
            System.out.println("年龄合法");
        }

    }
}
